#!/usr/bin/python
import os,sys

def grilla(n):
	nodos = n*n
	aristas = 2*n*(n-1)

	print "%d %d" % (nodos,aristas)
	for fi in range(0,n):
		for ci in range(0,n):
			for fj in range(fi,n):
				for cj in range(ci,n):
					if abs(fi-fj)+abs(ci-cj) == 1:
						print "%d %d" % (n*fi+ci,n*fj+cj)
def main():
	st = int(sys.argv[1])	
	end = int(sys.argv[2])
	gap = int(sys.argv[3])
	for i in range(st,end,gap):
		grilla(i)

if __name__ == "__main__":
	main()
